/*
 * @Author: Marte
 * @Date:   2016-10-24 16:42:55
 * @Last Modified by:   Marte
 * @Last Modified time: 2016-11-03 10:48:45
 */

'use strict';

/*var sequelizeService = require('../utils/sequelizeService');

var Remark = sequelizeService.models.Remark;*/

var oracledb = require('../utils/oracleUtil');
var _ = require('underscore');
var Promise = require('bluebird');

var controller = {

};

/**
 * [getJsonAll 获取评语]
 * @param  {[type]}   req  [description]
 * @param  {[type]}   res  [description]
 * @param  {Function} next [description]
 * @return {[type]}        [description]
 */
controller.getJsonAll = function(req, res, next) {
    var conn;
    oracledb.connection()
        .then(function(connection) {
            conn = connection;
            return conn.execute('Select * From remark');
        })
        .then(function(result) {
            conn.close();
            return res.status(200).json(result.rows);
        })
        .catch(function(err) {
            conn.close();
            return res.status(500).json({
                error: '读取数据出错！',
                syserror: err.message
            });
        });
};

controller.registerPath = function(router) {

    /*获取所有评语*/
    router.addPathGetHanlder('/api/remarks', controller.getJsonAll);

};


module.exports = controller;
